<script setup>
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
import ChartNew from './components/ChartNew.vue';
import { ref } from 'vue';
import axios from 'axios';


const tmp_data= ref({date:[],kline:[]})
const tmp_title = ref('test')
const cur_code = ref('sh.600000')
const cur_start = ref('2023-01-01')
const cur_end = ref('2023-03-01')


const get_data = ()=>{
  tmp_title.value = cur_start.value + '--' + cur_end.value
  axios({
    method: "get",
    url: "/data/get_kline",
    params: {code:cur_code.value, start:cur_start.value, end:cur_end.value}
  }).then((res)=>{
    console.log(res.data)
    tmp_data.value.date = res.data.data.date
    tmp_data.value.kline = res.data.data.kline
  })
}



</script>

<template>
  <div class="container">
    <div class="row align-items-start">
      <h1>Test</h1>
    </div>
    <div class="row">
    <div class="col">
      <div class="mb-3">
    <label for="exampleInputEmail1" class="form-label">Stock Code</label>
    <input type="text" class="form-control" id="exampleInputEmail1"  v-model="cur_code">
    <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">Start Time</label>
    <input type="text" class="form-control" id="exampleInputPassword1" v-model="cur_start">
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">End Time</label>
    <input type="text" class="form-control" id="exampleInputPassword2" v-model="cur_end">
  </div>

  <button  class="btn btn-primary" @click="get_data()">Submit</button>
  
    </div>
    <div class="col">
      <ChartNew :title=tmp_title :data=tmp_data></ChartNew>
    </div>
  </div>

  
 
  

  </div>
  

</template>

<style scoped>

</style>
